package com.lucenly.card.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.lucenly.card.R;
import com.lucenly.card.app.MyApplication;
import com.lucenly.card.base.BaseActivity;
import com.lucenly.card.event.StringMsgEvent;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.vise.xsnow.event.IEvent;
import com.vise.xsnow.event.Subscribe;

import butterknife.BindView;

/**
 * A login screen that offers login via email/password.
 */
public class LoginActivity extends BaseActivity  {
    @BindView(R.id.iv_cancel)
    ImageView iv_cancel;
    @BindView(R.id.rl_wx)
    RelativeLayout rl_wx;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void bindEvent() {
        C(iv_cancel);
        C(rl_wx);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void processClick(View view) {
        switch (view.getId()){
            case R.id.iv_cancel:
                finish();
                break;
            case R.id.rl_wx:
                SendAuth.Req req = new SendAuth.Req();
                req.scope = "snsapi_userinfo";
                req.state = "wechat_sdk_demo_test";
                MyApplication.getInstance().getApi().sendReq(req);
                break;
        }
    }
    @Override
    public boolean isRegisterEvent() {
        return true;
    }

    @Subscribe
    public void login(IEvent iEvent){
        if(iEvent!=null && iEvent instanceof StringMsgEvent){
            if(((StringMsgEvent) iEvent).getMsg().equals("login")){
                finish();
            }
        }
    }
}

